package com.demo1;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.AsyncContext;
import javax.servlet.ServletRequest;

public class Executor implements Runnable {
	private AsyncContext actx;
	public Executor(AsyncContext actx) {
		this.actx=actx;
	}

	@Override
	public void run() {
		try {
			//等待5秒模拟业务执行
			Thread.sleep(5000);
			ServletRequest request = actx.getRequest();
			List<String> list = new ArrayList<>();
			list.add("红楼梦");
			list.add("西游记");
			list.add("三国演义");
			list.add("水浒传");
			request.setAttribute("list", list);
			actx.dispatch("/async.jsp");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
